﻿using CpsyV2Web.DataAccess;
using CpsyV2Web.Models;
using System.Collections.Generic;
using System.Web.Http;

namespace CpsyV2Web.Controllers
{
    public class EchartsController : ApiController
    {
        /// <summary>
        /// 生成ECharts图表
        /// </summary>
        /// <param name="year">年份</param>
        /// <param name="month">月份</param>
        /// <param name="type">类型</param>
        /// <returns></returns>
        [HttpGet]
        public IEnumerable<Echarts> Post(int year, int month, string type)
        {
            if (type == "allData")
            {
                return PersonHelper.RetrieveAllData();
            }
            else if (type == "clickYear")
            {
                return PersonHelper.RetrieveYearData(year);
            }
            else if (type == "clickMonth")
            {
                return PersonHelper.RetrieveMonthData(year, month);
            }
            else if (type == "clickDay")
            {
                return PersonHelper.RetrieveAllData();
            }
            else 
                return null;
        }
    }
}
